package com.ostraffel.recallvocabularybackend.mapper.users.sqluserinterface;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.ostraffel.recallvocabularybackend.DTO.UserConfigDetailed;

@Mapper
public interface SqlUserInterface {

    @Select("SELECT * FROM recall_word.user WHERE userId = #{userId}")
    UserConfigDetailed searchUserConfig(@Param("userId") String userId);

    @Insert("INSERT INTO recall_word.user (userId, userName, userPassword, userEmail, newWordNumber, recallWordNumber) " +
            "VALUES (#{userId}, #{userName}, #{userPassword}, #{userEmail}, #{newWordNumber}, #{recallWordNumber})")
    void addUser(@Param("userId") String userId, @Param("userName") String userName, @Param("userPassword") String userPassword, @Param("userEmail") String userEmail, @Param("newWordNumber") int newWordNumber, @Param("recallWordNumber") int recallWordNumber);

    @Delete("DELETE FROM recall_word.user WHERE userId = #{userId}")
    void deleteUser(@Param("userId") String userId);

    @Update("UPDATE recall_word.user Set userName = #{username}")
    void updateUserName(@Param("username") String username);

    @Update("UPDATE recall_word.user Set userPassword = #{userPassword}")
    void updateUserPassword(@Param("userPassword") String userPassword);

    @Update("UPDATE recall_word.user Set userEmail = #{userEmail}")
    void updateUserEmail(@Param("userEmail") String userEmail);

    @Update("UPDATE recall_word.user Set newWordNumber = #{newWordNumber} where userId = #{userId}")
    void updateNewWordNumber(@Param("userId") String userId, @Param("newWordNumber") int newWordNumber);

    @Update("UPDATE recall_word.user Set recallWordNumber = #{recallWordNumber} where userId = #{userId}")
    void updateRecallWordNumber(@Param("userId") String userId, @Param("recallWordNumber") int recallWordNumber);

    @Update("UPDATE recall_word.user Set newWordNumber = #{newWordNumber}, recallWordNumber = #{recallWordNumber} where userId = #{userId}")
    void updateNewWordNumberAndRecallWordNumber(@Param("userId") String userId, @Param("newWordNumber") int newWordNumber, @Param("recallWordNumber") int recallWordNumber);

}
